<template>
  <el-container>
    <el-header height="80">
      <el-row :gutter="20">
        <el-col :offset="10" :span="5">
          <h1>教务系统——管理员页面</h1>
        </el-col>
        <el-col :offset="6" :span="2">
          <el-button type="danger" @click="logout">退出管理员账号</el-button>
        </el-col>
      </el-row>
    </el-header>
    <el-main style="margin-top: 50px;">
      <el-tabs v-model="activeTab">
        <el-tab-pane label="课程管理" name="1">
          <CourseManagement />
        </el-tab-pane>
        <el-tab-pane label="教师管理" name="2">
          <TeacherManagement />
        </el-tab-pane>
        <el-tab-pane label="成绩管理" name="3">
          <GradeManagement />
        </el-tab-pane>
        <el-tab-pane label="学生管理" name="4">
          <StudentManagement />
        </el-tab-pane>
      </el-tabs>
    </el-main>
  </el-container>
</template>

<script setup>
import { ref } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus';

import CourseManagement from '@/views/manager/components/CourseManagement.vue';
import TeacherManagement from '@/views/manager/components/TeacherManagement.vue';
import GradeManagement from '@/views/manager/components/GradeManagement.vue';
import StudentManagement from '@/views/manager/components/StudentManagement.vue';
import { useAdminStore } from '@/stores';
import { useRouter } from 'vue-router';

const router = useRouter();
const userStore = useAdminStore()
const activeTab = ref('1');
const logout = async () => {
  await ElMessageBox.confirm('确定要退出管理员账号吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  })
  userStore.removeToken()
  router.push('/login')

}
</script>

<style scoped>
.el-main {
  padding: 0 80px;
}

.el-header {
  background-color: #B3C0D1;
  color: white;
  text-align: center;
  line-height: 60px;
  font-size: 20px;
}
</style>
